# RUN: tf-mlir-translate -graphdef-to-mlir -tf-upgrade-legacy %s

# This is a stripped down GraphDef of the model from b/175240312. To hit the
# bug, the GraphDef needs to have functions in the library and also a Merge node
# to go into certain part of the functionalization code where it crashes.

node {
  name: "input"
  op: "Placeholder"
  attr {
    key: "dtype"
    value {
      type: DT_BOOL
    }
  }
}
node {
  name: "Switch0"
  op: "Switch"
  input: "input"
  input: "input"
  attr {
    key: "T"
    value {
      type: DT_BOOL
    }
  }
}
node {
  name: "func0"
  op: "func_name"
  input: "Switch0:1"
}
node {
  name: "Merge"
  op: "Merge"
  input: "Switch0:1"
  input: "Switch0"
  input: "^func0"
  attr {
    key: "N"
    value {
      i: 2
    }
  }
  attr {
    key: "T"
    value {
      type: DT_BOOL
    }
  }
}
library {
  function {
    signature {
      name: "func_name"
      input_arg {
        name: "arg0"
        type: DT_BOOL
      }
    }
    ret {
      key: "retval0"
      value: "arg0"
    }
  }
}
